#pragma once
#include "mixer.h"

#define VOLUME_SPEAKER			0
#define VOLUME_MICROPHONE		1
#define VOLUME_REC_MICROPHONE	2

#define CHANGE_MUTE_STATE	0
#define CHANGE_VOLUME		1

class CVolumeControl;

typedef void (CALLBACK *PONMICVOULUMECHANGE)(CVolumeControl *pVolumeControl, DWORD dwVolumeType, DWORD dwChangeType, DWORD dwUserValue );

class CVolumeControl : public CMixerEventReceiver
{
public:
	CVolumeControl(DWORD nVolumeType);
	~CVolumeControl(void);
public:
	const DWORD m_nVolumeType;
	UINT m_uMixerID;
public:
	bool	GetMute();
	void	SetMute(bool bMute = true);
	DWORD	GetVolumeMetric();
	DWORD	GetMinimalVolume();
	DWORD	GetMaximalVolume();
	DWORD	GetCurrentVolume();
	void	SetCurrentVolume( DWORD dwValue );
	void	RegisterNotificationSink( PONMICVOULUMECHANGE, DWORD );
private:
	bool	Init();
	void	Done();
	bool	Initialize();
private:
	// Status Info
	bool	m_bOK;
	bool	m_bInitialized;
	bool	m_bAvailable;

	// Mixer Info
	CMixer *m_pMixer;
	HMIXER	m_hMixerHandle;

	DWORD	m_dwMixerLineType;
	DWORD	m_dwLineID;
	DWORD	m_dwVolumeControlID;
	DWORD	m_dwMuteControlID;
	int		m_nChannelCount;
	
	void	OnControlChanged(CMixer *pMixer, DWORD dwControlID);

	DWORD	m_dwMinimalVolume;
	DWORD	m_dwMaximalVolume;
	DWORD	m_dwVolumeStep;

	// User Info
	PONMICVOULUMECHANGE		m_pfUserSink;
	DWORD					m_dwUserValue;
};

typedef	CVolumeControl*	PCVolumeControl;
